package com.yang.exception;

import com.yang.exception.annotation.Unit;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.HashSet;

/**
 * @ClassName UnitValidator
 * @Description TODO
 * @Author zhangdongdong
 * @Date 2022/9/9 9:21
 * @Version 1.0
 */
public class UnitValidator implements ConstraintValidator<Unit, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        HashSet<Object> unit = new HashSet<>();
        unit.add("件");
        unit.add("个");
        unit.add("盒");
        return unit.contains(value);
    }
}
